<?php
namespace QuestionPlus\Service\Import\QuestionImport;

class QuestionImportFactory
{
    private static $cached = array();

    public static function create($target, $importType, $type)
    {
        $questionType = $type;
        if (in_array($type, array('single_choice', 'uncertain_choice'))) {
            $type = 'choice';
        }

        if (empty(self::$cached[$questionType])) {
            $ucType = ucfirst($type);
            $class = __NAMESPACE__  . "\\{$ucType}QuestionImport";
            self::$cached[$questionType] = new $class($target, $importType, $type, $questionType);
        }

        return self::$cached[$questionType];
    }
}